package com.woniu.atms.util;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * @author 张奇
 * @title: ResponseResult
 * @projectName wn_sb_rbac12-21
 * @description: TODO
 * @date 2021/12/21 11:01
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class ResponseResult<T> {

    /**
     * 响应码
     */
    private int code;


    /**
     * 响应描述
     */
    private String msg;

    /**
     * 响应数据
     */
    private T data;

    public ResponseResult(T data) {
        this(Code.SUCCESS.getCode(), "success", data);
    }

    public ResponseResult(Code code, String msg) {
        this(code.getCode(), msg, null);
    }

    public ResponseResult(Code code, String msg, T data) {
        this(code.getCode(), msg, data);
    }


    public static final ResponseResult SUCCESS = new ResponseResult(Code.SUCCESS, "操作成功");
    public static final ResponseResult FAIL = new ResponseResult(Code.FAIL, "操作失败");
    public static final ResponseResult ERROR = new ResponseResult(Code.ERROR, "服务器错误");


}

